package com.evenmo.controller;

import com.evenmo.pojo.Clazz;
import com.evenmo.service.ClazzService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;

/**
 * This is Description
 *
 * @author moyongjun
 * @date 2019/12/06
 */
@Controller
@RequestMapping(value = "/clazz")
public class ClazzController {

    private Logger logger = LoggerFactory.getLogger(ClazzController.class);

    @Resource
    private ClazzService clazzService;
    @RequestMapping(value = "/clazzid",method = RequestMethod.GET)
    @ResponseBody
    public Clazz getClazzById(Integer id){

        Clazz clazz = clazzService.queryById(id);


        logger.info(clazz.toString());
        return   clazz;
    }
@RequestMapping(value = "/allClazz",method = RequestMethod.GET)
@ResponseBody
public List<Clazz> getAll(){
        return clazzService.queryAll();
    }


    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public String clazzList(Model model){
        List<Clazz> clazzes = clazzService.queryAll();
        model.addAttribute("clazzes", clazzes);
        return "clazz/list";
    }



}
